home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / tidict_1 / tidict~1.exe / Viewer / DictListView.ctl next >
Encoding:
Text File  |  1998-06-20  |  4.8 KB  |  166 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
  3. Begin VB.UserControl DictListView 
  4.    ClientHeight    =   3375
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   4590
  8.    ScaleHeight     =   3375
  9.    ScaleWidth      =   4590
  10.    Begin ComctlLib.ListView LV 
  11.       Height          =   2415
  12.       Left            =   0
  13.       TabIndex        =   0
  14.       Top             =   0
  15.       Width           =   2715
  16.       _ExtentX        =   4789
  17.       _ExtentY        =   4260
  18.       View            =   3
  19.       LabelEdit       =   1
  20.       LabelWrap       =   -1  'True
  21.       HideSelection   =   -1  'True
  22.       _Version        =   327682
  23.       Icons           =   "ImageList1"
  24.       SmallIcons      =   "ImageList1"
  25.       ForeColor       =   -2147483640
  26.       BackColor       =   -2147483643
  27.       Appearance      =   1
  28.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  29.          Name            =   "MS Sans Serif"
  30.          Size            =   8.25
  31.          Charset         =   204
  32.          Weight          =   400
  33.          Underline       =   0   'False
  34.          Italic          =   0   'False
  35.          Strikethrough   =   0   'False
  36.       EndProperty
  37.       NumItems        =   3
  38.       BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
  39.          Key             =   "Name"
  40.          Object.Tag             =   ""
  41.          Text            =   "Name"
  42.          Object.Width           =   2540
  43.       EndProperty
  44.       BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
  45.          Key             =   "Type"
  46.          Object.Tag             =   ""
  47.          Text            =   "Type"
  48.          Object.Width           =   1270
  49.       EndProperty
  50.       BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
  51.          Key             =   "Value"
  52.          Object.Tag             =   ""
  53.          Text            =   "Value"
  54.          Object.Width           =   5080
  55.       EndProperty
  56.    End
  57.    Begin ComctlLib.ImageList ImageList1 
  58.       Left            =   3840
  59.       Top             =   2700
  60.       _ExtentX        =   1005
  61.       _ExtentY        =   1005
  62.       BackColor       =   -2147483643
  63.       ImageWidth      =   16
  64.       ImageHeight     =   16
  65.       MaskColor       =   16777215
  66.       _Version        =   327682
  67.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  68.          NumListImages   =   2
  69.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  70.             Picture         =   "DictListView.ctx":0000
  71.             Key             =   ""
  72.          EndProperty
  73.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  74.             Picture         =   "DictListView.ctx":031A
  75.             Key             =   ""
  76.          EndProperty
  77.       EndProperty
  78.    End
  79. End
  80. Attribute VB_Name = "DictListView"
  81. Attribute VB_GlobalNameSpace = False
  82. Attribute VB_Creatable = True
  83. Attribute VB_PredeclaredId = False
  84. Attribute VB_Exposed = False
  85. Option Explicit
  86.  
  87. Dim mPath As String
  88.  
  89. Public Event OpenItem(ByVal ItemName As String)
  90.  
  91. Public Property Get Path() As String
  92.   Path = mPath
  93. End Property
  94.  
  95. Public Property Let Path(ByVal vNewValue As String)
  96.   
  97.   Dim i As TIDICTIONARYLib.Item, LI As ListItem
  98.   
  99.   mPath = vNewValue
  100.   LV.ListItems.Clear
  101.   If mPath = "@" Then
  102.     Dict.GoPath mPath ' or  Dict.GoRoot
  103.   Else
  104.     Dict.GoPath(mPath).Open
  105.     LV.ListItems.Add , "..", "..", 2, 2
  106.   End If
  107.     
  108.   On Error Resume Next
  109.   For Each i In Dict
  110.     If i.IsDictionary Then
  111.       Set LI = LV.ListItems.Add(, i.Name, i.Name, 1, 1)
  112.     Else
  113.       Set LI = LV.ListItems.Add(, i.Name, i.Name)
  114.       LI.SubItems(1) = TypeName(i.Value)
  115.       LI.SubItems(2) = CStr(i.Value)
  116.       If Err.Number Then LI.SubItems(3) = "(Error)"
  117.     End If
  118.     Set LI = Nothing
  119.   Next
  120. End Property
  121.  
  122. Private Sub LV_DblClick()
  123.   If Not LV.SelectedItem Is Nothing Then
  124.     If LV.SelectedItem.Icon Then RaiseEvent OpenItem(LV.SelectedItem.Key)
  125.   End If
  126. End Sub
  127.  
  128. Private Sub UserControl_Resize()
  129.   On Error Resume Next
  130.   LV.Move ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight
  131. End Sub
  132.  
  133. Private Function UniqueControlName()
  134.   On Error Resume Next
  135.   Dim N$
  136.   N = Extender.Name
  137.   N = N & Extender.Index
  138.   UniqueControlName = N
  139. End Function
  140.  
  141. ' state persisting methods
  142. Public Sub ReadState(St As Dictionary)
  143.   On Error GoTo ExitSub
  144.   St(UniqueControlName()).Open
  145.     Dim CH As ColumnHeader
  146.     For Each CH In LV.ColumnHeaders
  147.       CH.Width = St(CH.Key).Value
  148.     Next
  149.   St.Close
  150. ExitSub:
  151.   Err.Clear
  152. End Sub
  153.  
  154. Public Sub WriteState(St As Dictionary)
  155.   On Error GoTo ExitSub
  156.   St.Add(UniqueControlName()).Open
  157.     Dim CH As ColumnHeader
  158.     For Each CH In LV.ColumnHeaders
  159.       St.Add(CH.Key).Value = CH.Width
  160.     Next
  161.   St.Close
  162. ExitSub:
  163.   Err.Clear
  164. End Sub
  165.  
  166.